//
//  NSMutableDictionaryAdditions.m
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "NSMutableDictionaryAdditions.h"
#import "TTCore.h"


@implementation NSMutableDictionary (Tint)


#pragma mark - Adding entries

- (void)setObject:(id)object forKeyIfNotNil:(id)key {
    if (object && key) {
        [self setObject:object forKey:key];
    }
}

- (void)setPoint:(CGPoint)value forKey:(NSString *)key {
    NSDictionary *dictionary = (NSDictionary *)CGPointCreateDictionaryRepresentation(value);
    [self setObject:dictionary forKeyIfNotNil:key];
    TTRelease(dictionary);
}

- (void)setSize:(CGSize)value forKey:(NSString *)key {
    NSDictionary *dictionary = (NSDictionary *)CGSizeCreateDictionaryRepresentation(value);
    [self setObject:dictionary forKeyIfNotNil:key];
    TTRelease(dictionary);
}

- (void)setRect:(CGRect)value forKey:(NSString *)key {
    NSDictionary *dictionary = (NSDictionary *)CGRectCreateDictionaryRepresentation(value);
    [self setObject:dictionary forKeyIfNotNil:key];
    TTRelease(dictionary);
}

@end
